package com.huiztech.watersoil.activity;

import com.huiztech.watersoil.R;
import com.huiztech.watersoil.R.anim;
import com.huiztech.watersoil.R.drawable;
import com.huiztech.watersoil.R.layout;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Window;
import android.view.WindowManager;

/**
 * 欢迎页界面
 * 
 * @author alin
 * 
 */
public class WelcomeActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		super.onCreate(savedInstanceState);

		// 设置背景颜色
		Resources res = getResources();
		Drawable drawable = res.getDrawable(R.drawable.bgcolor);
		this.getWindow().setBackgroundDrawable(drawable);

		setContentView(R.layout.welcome);

		new CountDownTimer(2000, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {
			}

			@Override
			public void onFinish() {
				Intent intent = new Intent();
				intent.addCategory(Intent.CATEGORY_HOME);// 后台运行
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);// 后台运行
				intent.setClass(WelcomeActivity.this, MainActivity.class);
				startActivity(intent);

				int VERSION = Integer.parseInt(android.os.Build.VERSION.SDK);
				if (VERSION >= 5) {
					// 从右往左推
					overridePendingTransition(R.anim.push_left_in,
							R.anim.push_left_out);
					// 中间放大出来
					// overridePendingTransition(R.anim.my_scale_action,R.anim.my_alpha_action);
					// 中间旋转出来1
					// overridePendingTransition(R.anim.scale_rotate,R.anim.my_alpha_action);
					// 中间旋转出来2
					// overridePendingTransition(R.anim.scale_translate_rotate,R.anim.my_alpha_action);
					// 左上角放大出来
					// overridePendingTransition(R.anim.scale_translate,R.anim.my_alpha_action);
					// 上下压缩消失
					// overridePendingTransition(R.anim.hyperspace_in,R.anim.hyperspace_out);
					// 从下往上推
					// overridePendingTransition(R.anim.push_up_in,R.anim.push_up_out);
					// 左右出来，新覆盖旧
					// overridePendingTransition(R.anim.slide_left,R.anim.slide_right);
					// 放大淡出
					// overridePendingTransition(R.anim.wave_scale,R.anim.my_alpha_action);
					// 下的往上，上的往下
					// overridePendingTransition(R.anim.slide_up_in,R.anim.slide_down_out);
					// 旧的中间往左上角，新的中间缩小淡出
					// overridePendingTransition(R.anim.zoom_enter,R.anim.zoom_exit);
					// 淡入淡出
					// overridePendingTransition(R.anim.fade, R.anim.hold);
					// 淡入淡出
					// WelcomeActivity.this.overridePendingTransition(R.layout.fade_in,
					// R.layout.fade_out);
				}
				finish();
			}
		}.start();
	}
}
